var appid = '';
var token = '';
$(document).ready(function() {
	//获取token，调用API服务
	auth();
});
//初始化  获取token值
function auth() {
	$.ajax({
		type: 'get',
		//async:false,
		url: "http://v2.mashupcloud.cn/developer/auth.do/",
		data: {
			appkey: 'IwgITBdJsnUgJQwKWfjGxrDjmRDqnURh',
			appsecret: 'tnDXgDWoFOwvysUSdiMQAieAQfLCXxTn'

		},
		//dataType: "json",
		success: function(json) {
			var jo = eval(json);
			var token = jo[1];
			var appid = jo[2];
			sessionStorage.setItem("token", token);
			sessionStorage.setItem("appid", appid);
			//用户注册
			user_register(token, appid);
		},
		error: function(json) {
			console.log("err:" + json);
		}
	});
}
//用户注册
function user_register(token, appid) {
	$.ajax({
		type: 'get',
		url: "http://v2.mashupcloud.cn/SQL/reg/",
		data: {
			appid: appid,
			token: token,
			name: 'reg',
			_v1: vue.phone, //参数1  _v3,_v4 .......
			_v2: vue.pwd1 //参数2
		},
		success: function(json) {
			console.log("json==" + json);
			sessionStorage.setItem("username", vue.phone);
			location.href = "../youlike/youlike.html";
		},
		error: function(json) {
			console.log("err:" + json);
		}
	});
}
//用户登录
/*function user_load(token, appid) {
	$.ajax({
		type: 'get',
		url: "http://v2.mashupcloud.cn/SQL/load/",
		data: {
			appid: appid,
			token: token,
			name: 'load',
			_v1: "", //参数1  _v3,_v4 .......
			_v2: "" //参数1  _v3,_v4 .......
		},
		success: function(json) {
			console.log("json==" + json);
			//			sessionStorage.setItem("nickname",vue.phone);
			location.href = "../home/home.html";
		},
		error: function(json) {
			console.log("err:" + json);
		}
	});
}*/